Try to create runtime xenstored's directories at startup time.
authorvhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Thu, 11 May 2006 14:01:54 +0000 (15:01 +0100)
committervhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Thu, 11 May 2006 14:01:54 +0000 (15:01 +0100)
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
tools/xenstore/xenstored_core.c
tools/xenstore/xs_lib.c
tools/xenstore/xs_lib.h

index a79e2dcf0c07e01556dc82fa94539fe6cfe7da62..2dcf9cf591af65f182c4288859fb2fb733d4913c 100644 (file)
@@ -1811,6 +1811,21 @@ int main(int argc, char *argv[])
 
        reopen_log();
 
+       /* make sure xenstored directory exists */
+       if (mkdir(xs_daemon_rundir(), 0755)) {
+               if (errno != EEXIST) {
+                       perror("error: mkdir daemon rundir");
+                       exit(-1);
+               }
+       }
+
+       if (mkdir(xs_daemon_rootdir(), 0755)) {
+               if (errno != EEXIST) {
+                       perror("error: mkdir daemon rootdir");
+                       exit(-1);
+               }
+       }
+
        if (dofork) {
                openlog("xenstored", 0, LOG_DAEMON);
                daemonize();
index 226a8487f73f960f3dc4953977ec79ed90ededa3..750d1823cf8dab84706cc8a4df9fe7fe28e0a379 100644 (file)
 
 /* Common routines for the Xen store daemon and client library. */
 
-static const char *xs_daemon_rootdir(void)
+const char *xs_daemon_rootdir(void)
 {
        char *s = getenv("XENSTORED_ROOTDIR");
        return (s ? s : "/var/lib/xenstored");
 }
 
-static const char *xs_daemon_rundir(void)
+const char *xs_daemon_rundir(void)
 {
        char *s = getenv("XENSTORED_RUNDIR");
        return (s ? s : "/var/run/xenstored");
index c62c457e616db3bae73647c421d6fcda5fab2aec..f55008281add7f3f299871d3718132638c6ddd09 100644 (file)
@@ -46,6 +46,8 @@ struct xs_permissions
 #define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2)
 
 /* Path for various daemon things: env vars can override. */
+const char *xs_daemon_rootdir(void);
+const char *xs_daemon_rundir(void);
 const char *xs_daemon_socket(void);
 const char *xs_daemon_socket_ro(void);
 const char *xs_domain_dev(void);